package me.algo.array;

import java.util.HashSet;

/**
 * @author guozheng
 * @date 2024/4/15
 */
public class A3 {


    public static void main(String[] args) {
        int[] nums = {1, 2, 3, 1};
        System.out.println(containsDuplicate(nums));
    }
    /**
//    217. 存在重复元素

     * @param nums
     * @return
     */
    public static boolean containsDuplicate(int[] nums) {
        if (nums == null || nums.length == 0) {
            return false;
        }
        HashSet<Integer> objects = new HashSet<>();
        for (int num : nums) {
            if (objects.contains(num)) {
                return true;
            }
            objects.add(num);
        }
        return false;

    }
}
